package core.battle
{
	public class RockObject extends GameObject
	{
		private var _speed : Number = 1e-1;
		private var _whirlSpeed : Number = 1e-1;
		
		private var _maxSpeed : Number = 2e-1;
		private var _maxWhirlSpeed :Number = 2e-1;
	
		private var _rockHeight : Number = 50;
		private var _rockWidth : Number = 20;

		private var _minSize : Number = 10;
		private var _addSize : Number = 50;
		
		private var _color : uint = 0x500000;
		
		private var _colorPool : Array = [ 
			0xD20639,
			0xF32F2F,
			0xDA9A83,
			0xFCBC55,
			0xFAE779,
			0xDEDF94,
			0xB6FA09,
			0x2DE005,
			0x26855C,
			0x09C5F4,
			0x1273FB,
			0x3F46C8,
			0xB8B1FA,
			0xA050FB,
			0xD303DE,
			0xBA016D];
		
		public function RockObject()
		{
			super();
		}

		public function resetSpeed() : void {
			_speed = _maxSpeed * Math.random();
			_whirlSpeed = _maxWhirlSpeed * ( 2 * Math.random() - 1 );
		}
		
		override public function init():void {
			_color = _colorPool[ int( Math.random() * 16 ) % _colorPool.length ];
			trace(_color);
			graphics.clear();
			graphics.beginFill( _color );
			_rockWidth = _minSize + Math.random()*_addSize;
			_rockHeight = _minSize + Math.random()*_addSize;
			graphics.drawRect( -0.5*_rockWidth , -0.5*_rockHeight , _rockWidth , _rockHeight );
			graphics.endFill();
		}
		
		override public function update(deltaTime:Number):void {
			super.update(deltaTime);
			x -= deltaTime * Game.getInstance().forwardSpeed;
			rotationZ += deltaTime * _whirlSpeed;
		}
	}
}